package com.twu.biblioteca;

import java.util.Iterator;

/**
 * Created with IntelliJ IDEA.
 * User: mini server
 * Date: 9/20/13
 * Time: 12:20 PM
 * To change this template use File | Settings | File Templates.
 */
public class UtilityInventory
{
   private static boolean hasSameItems(Inventory one, Inventory two)
   {
       Iterator iterOne = one.returnIterator();
       Iterator iterTwo = two.returnIterator();

       while(iterOne.hasNext()) // Book needs to be programmed to more generic type
       {
           Book bookOne = (Book) iterOne.next();
           Book bookTwo = (Book) iterTwo.next();

           if (!bookOne.equals(bookTwo))
           {
                return false;
           }

       }

       return true;
   }

   public static boolean isSameInventories(Inventory one, Inventory two)
   {
      return one.typeOfInventory() == two.typeOfInventory() && one.numOfItemsInInventory() == two.numOfItemsInInventory()
              && hasSameItems(one,two);
   }
}
